<%--
  Created by IntelliJ IDEA.
  User: PC
  Date: 2024/3/22
  Time: 12:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>选择类型</title>
    <script>
        function validateSelection() {
            var selectElement = document.getElementById('typeSelection');
            var selectedValue = selectElement.value;

            // 检查是否选择了默认选项或其他有效选项
            if (selectedValue === "default" || selectedValue !== "") {
                // 选择有效，允许提交表单
                return true;
            } else {
                // 没有选择有效选项，提示用户
                alert('请选择一个类型！');
                return false;
            }
        }
    </script>
</head>
<body>
<h3>添加商品</h3>
<form onsubmit="return validateSelection()" action="/logindemo2/addGoods" method="post">
    商品名称:<input name="goodsName" value="" required><br>
    商品信息:<input name="goodsMessage" value="" required><br>
    商品价格:<input type="number"  name="price" min="1" required><br>
    商品库存:<input type="number"  name="goodsNum" min="1" required><br>


    <label for="typeSelection">请选择一个类型：</label>
    <select id="typeSelection" name="typeSelection">
        <option value="默认" selected>默认</option>
        <option value="服装">服装</option>
        <option value="首饰">首饰</option>
        <option value="数码">数码</option>
        <option value="文具">文具</option>
    </select>
    <!--<input type="submit" value="提交">-->
    <button type="submit">提交</button>
</form>
</body>
</html>
